// src/config.ts
import type { SourceFormat, NodeSemanticType } from '@/models/universalFlow';
// Import Position type for Controls
import type { PanelPosition } from '@vue-flow/core';

/**
 * Application configuration and feature flags.
 */
export interface AppConfig {
    // --- Universal Editor Features ---
    enableUniversalParser: boolean;       // Enables parsing of JSON, YAML, TOML (future) via universal flow
    enableMultiFormatUpload: boolean;   // Allows uploading JSON, YAML, TOML files for universal view
    showUniversalViewRoute: boolean;      // Shows the '/universal-editor' route in the navigation

    // --- Visualizer Control Flags ---
    showMiniMap: boolean;
    showControls: boolean;
    showBackground: boolean;
    enableNodeToolbar: boolean; // Flag for NodeToolbar
    enableBlobityEffect: boolean; // Flag for Blobity custom cursor effect

    // --- Controls Component Configuration ---
    controlsShowZoom: boolean;        // Show Zoom In/Out buttons
    controlsShowFitView: boolean;     // Show Fit View button
    controlsShowInteractive: boolean; // Show Lock/Unlock button
    controlsPosition: PanelPosition;  // Position ('top-left', 'top-right', 'bottom-left', 'bottom-right')

    // --- Custom Control Button Flags ---
    controlsShowRedoLayout: boolean;  // Show Redo Layout button
    controlsShowToggleOrientation: boolean; // Show Toggle Orientation button

    // --- Other Potential Flags ---
    // enableAdvancedXmlFeatures: boolean; // Example: Enable schema validation, XPath etc. for XML
    // debugMode: boolean;               // Example: Enable extra logging or debug UI
}

// Default configuration for the student's project version (universal features off)
// Change these flags to `true` when you want to enable/test the universal editor features.
const config: AppConfig = {
    enableUniversalParser: false,
    enableMultiFormatUpload: false,
    showUniversalViewRoute: false, // Keep false initially for student's version

    // --- Default Control Visibility ---
    showMiniMap: true,
    showControls: true,
    showBackground: true,
    enableNodeToolbar: true,
    enableBlobityEffect: true,  // Enable Blobity by default

    // --- Default Controls Settings ---
    controlsShowZoom: true,
    controlsShowFitView: true,
    controlsShowInteractive: true,
    controlsPosition: 'bottom-left' as PanelPosition,

    // --- Default Custom Controls Visibility ---
    controlsShowRedoLayout: true, // Show by default
    controlsShowToggleOrientation: true, // Show by default
};

/**
 * Maps SourceFormat to specific color codes for tags/labels.
 * Export this directly so it can be imported by name.
 */
export const formatColorCodes: Record<SourceFormat, string> = {
    xml: '#409EFF',    // Element Plus Blue
    json: '#67C23A',   // Element Plus Green
    yaml: '#E6A23C',   // Element Plus Orange
    toml: '#F56C6C',   // Element Plus Red
    javascript: '#f7df1e', // Standard JS Yellow
    typescript: '#3178c6', // Standard TS Blue
    unknown: '#909399' // Element Plus Gray
};

/**
 * Maps NodeSemanticType to specific color codes for node backgrounds.
 * Used for base semantic coloring and for non-element/object types in other modes.
 */
export const semanticTypeColorCodes: Record<NodeSemanticType, string> = {
    root: '#ef467e',      // Pink
    element: '#0ea5e9',   // Blue 
    object: '#4ADE80',    // Green 
    array: '#FACC15',     // Yellow
    value: '#f97316',     // Orange
    comment: '#9ca3af',    // Gray
    // --- Add colors for new types --- 
    functionCall: '#8b5cf6',         // Violet 500
    variableReference: '#6366f1',    // Indigo 500
    memberExpression: '#ec4899',     // Pink 500
    binaryExpression: '#d946ef',     // Fuchsia 500
    unaryExpression: '#a855f7',      // Purple 500
    conditionalExpression: '#f43f5e',// Rose 500
    templateLiteral: '#14b8a6',     // Teal 500
    newExpression: '#22c55e',        // Green 500
};

/**
 * Default background color for element/object nodes when no specific rule matches.
 * Choose a neutral, soft color.
 */
export const defaultElementObjectColor = '#e2e8f0'; // Example: Slate 200 (Tailwind)

/**
 * Color palette for coloring nodes based on level/depth.
 * A sequence of visually distinct but harmonious colors.
 */
export const levelColorPalette: string[] = [
  '#a5f3fc', // Cyan 200
  '#a7f3d0', // Emerald 200
  '#fecaca', // Red 200
  '#fed7aa', // Orange 200
  '#d8b4fe', // Purple 200
  '#fbcfe8', // Pink 200
  '#bfdbfe', // Blue 200
  '#bbf7d0', // Green 200
  '#fde68a', // Amber 200
  // Add more colors if needed, they will cycle
];

/**
 * Specific colors for core JDF element tags.
 * Define colors for important JDF elements here.
 */
export const jdfCoreTagColorCodes: Record<string, string> = {
  JDF: '#ef467e', // Match root semantic color
  ResourcePool: '#1d4ed8', // Deep Blue
  IntentPool: '#047857', // Deep Green
  Component: '#ea580c', // Deep Orange
  Device: '#7e22ce', // Deep Purple
  Media: '#be123c', // Deep Red
  RunList: '#ca8a04', // Deep Yellow/Gold
  Process: '#16a34a', // Medium Green
  AuditPool: '#64748b', // Slate 500
  NodeInfo: '#475569', // Slate 600
  ResourceLinkPool: '#52525b', // Zinc 600
  ComponentLink: '#f97316', // Orange (like value)
  MediaLink: '#f87171', // Light Red
  DeviceLink: '#a78bfa', // Light Purple
  // Add more core JDF tags as needed
};

// Ensure config is exported as default
export default config;